<?php
class Merchant_Model_Validate_Rm1rValidate extends Merchant_Model_Validate_CommonValidate{

    public function validator(){
		$this->PublicValidator();
		$this->orderProduct();			//物品描述
		$this->consigneeRegion();		//收件人州
		$this->consigneeCity();
		$this->consigneeZip();
		$this->consigneePhone();
				
        return $this->_error;
    }
	
    public function shippingMethod(){}
    public function consigneeCountryId(){}
	
	//邮编
	public function zipCode(){
		$regex = array('name' => '收件邮编','value' => $this->consignee_zip,'regex' => array('length[0,32]','noCharacter','require'));
		$error=Default_Service_Validator::Validator($regex);
		if(!empty($error)){
			$this->_error[] = $error ;
		}
	}
    
    //收件人州
	public function consigneeRegion(){

		$regex = array('name' => '收件人州','value' => $this->consignee_region,'regex' => array('length[1,128]','noCharacter'));
        $countryIdArr = array(252);
        if(in_array($this->consignee_country_id,$countryIdArr)){
            $regex["regex"][] = 'require';
        }
		$error=Default_Service_Validator::Validator($regex);
		if(!empty($error)){
			$this->_error[] = $error ;
		}
	}
	
	//收件人城市
	public function consigneeCity(){

		$regex = array('name' => '收件人城市','value' => $this->consignee_city,'regex' => array('length[1,255]','noCharacter'));
        $countryIdArr = array(252);
        if(in_array($this->consignee_country_id,$countryIdArr)){
            $regex["regex"][] = 'require';
        }
		$error=Default_Service_Validator::Validator($regex);
		if(!empty($error)){
			$this->_error[] = $error ;
		}

	}
	
	//收件人地址
	public function address(){

        $address1Len = 30;
		$address2Len = 60;
        $regex[1] = array('name' => '收件地址1','value' => $this->consignee_address1,'regex' => array('require','noCharacter','length[5,'.$address1Len.']'));
        $regex[2] = array('name' => '收件地址2','value' => $this->consignee_address2,'regex' => array('noCharacter','length[0,'.$address2Len.']'));     
		$error= Default_Service_Validator::formValidator($regex);

		if(!empty($error)){
			foreach ($error as $one){
			    $this->_error[] = $one ;
			}
		}
	}
	
	//电话
	public function consigneePhone(){
 		$regex = array('name' =>  '电话号码','value' => $this->consignee_phone,'regex' => array('length[0,20]','noCharacter'));
		$error = Default_Service_Validator::Validator($regex);
		if(!empty($error)){
			$this->_error[] = $error ;
		}
	}
    
    
}
?>